local ClearEntry = class("ClearEntry", require("app.views.slots.task.TaskEntry"))
local Config = require("app.views.slots.Config")

--[[
clearData = {
    [1] = {2,4}, -- 第1列第2个，第1列第4个
    [2] = {1}, -- 第2列第1个
}]]
function ClearEntry:ctor(clearData, reels)
    ClearEntry.super.ctor(self)
    self._clearData = clearData
    self._reels = reels
    self._timer = 0
    self:addToQueue(self, self._init)
    self:addToQueue(self, self._step)
end

function ClearEntry:_init()
    local targetSymbols = {}
    local otherSymbols = {}
    for col, reel in ipairs(self._reels) do
        local symbols = reel:getSymbols()
        for i, symbol in ipairs(symbols) do
            local tid = symbol:getTid()

            if  self._clearData[col] and table.contains( self._clearData[col], i) then
                table.insert(targetSymbols, symbol)
            else
                table.insert(otherSymbols, symbol)
            end
        end
    end

    for _, symbol in ipairs(targetSymbols) do
        symbol:playClearEffect()
    end
    for _, symbol in ipairs(otherSymbols) do
        symbol:enableMask(true)
    end
    return true
end

function ClearEntry:_step(dt)
    self._timer = self._timer + dt
    if self._timer > 1.5 then
        -- for _, symbol in ipairs(self._targetSymbols) do
        --     symbol:playClearEffect()
        -- end
        -- for _, symbol in ipairs(self._otherSymbols) do
        --     symbol:enableMask(false)
        -- end
        print("clear finished")
        return true
    end
end

return ClearEntry